package goldensoftware.pdv.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Dao
{
	
	private static Connection connection;
	
	public Dao()
	{
		try
		{
			Class.forName("org.postgresql.Driver");
			connection = DriverManager.getConnection("jdbc:postgresql://localhost/pdv", "postgres", "xray");
		} 
		catch (ClassNotFoundException cnfe){
			System.out.println("Could not find the JDBC driver!");
			System.exit(1);
		} 
		catch (SQLException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	protected Connection getConnection()
	{
		return connection;
	}

//	try{
//    Class.forName("org.postgresql.Driver");
//    } catch (ClassNotFoundException cnfe){
//      System.out.println("Could not find the JDBC driver!");
//      System.exit(1);
//    }
//Connection conn = null;
//try {
//    conn = DriverManager.getConnection("jdbc:postgresql://localhost/pdv", "postgres", "xray");
//    Statement stm = conn.createStatement();
//    ResultSet rs = stm.executeQuery("select * from usuario");
//    while(rs.next())
//    {
////    	int int1 = rs.getInt(0);
//    	String string = rs.getString(1);
//    	String string2 = rs.getString(2);
//    	
//    	System.out.println();
//    }
//     } catch (SQLException sqle) {
//       System.out.println("Could not connect");
//       System.exit(1);
//     }

}
